


<!DOCTYPE html>
<html id="htmlId">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
  <title>Coverage Report > ResponseResult</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/idea.min.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.min.js"></script>
  <script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">com.ie.common.http</a>
</div>

<h1>Coverage Summary for Class: ResponseResult (com.ie.common.http)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Branch, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">ResponseResult</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/18)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/46)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/23)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package com.ie.common.http;
&nbsp;
&nbsp;import lombok.Data;
&nbsp;
&nbsp;import java.util.List;
&nbsp;import java.util.Map;
&nbsp;
&nbsp;/**
&nbsp; * @classname: ResponseResult
&nbsp; * @Author: royxu
&nbsp; * @Description: 定义了一个泛型类。泛型类允许你在定义类时指定一个或多个类型参数，这样在创建类的实例时可以指定具体的类型，
&nbsp; * 这个类通常用于封装服务器返回的数据，包括状态码、消息和具体的数据。使用泛型可以使得这个类能够处理不同类型的数据，而不需要为每种数据类型定义不同的类。
&nbsp; * &lt;a href=&quot;https://blog.csdn.net/m0_64720511/article/details/124271866&quot;&gt;...&lt;/a&gt;
&nbsp; * @Date: 2025/4/17  7:39
&nbsp; * @Param: 泛型参数：&lt;T&gt; 表示这是一个泛型类，T 是类型参数，可以在创建类的实例时指定具体的类型。
&nbsp; * @version: 1.0
&nbsp; **/
<b class="nc">&nbsp;@Data</b>
&nbsp;public class ResponseResult&lt;T&gt; {
&nbsp;
&nbsp;    //	存储操作结果的数据
<b class="nc">&nbsp;    private T result;</b>
&nbsp;    /**
&nbsp;     * 表示操作的状态码
&nbsp;     * C200:正常
&nbsp;     * C401:认证不通过
&nbsp;     * C404:未找到资源
&nbsp;     * C405:权限不足
&nbsp;     * C500:服务异常
&nbsp;     */
<b class="nc">&nbsp;    private StatusCode statusCode;</b>
&nbsp;    /**
&nbsp;     * 消息的唯一标识符
&nbsp;     * msgId类型,系统里用到的A001，A002,A003
&nbsp;     * A000:
&nbsp;     * BUser：验证码错误
&nbsp;     * A001: 失败
&nbsp;     * AUser:用户名错误
&nbsp;     * BUser:
&nbsp;     * login：邮箱已存在
&nbsp;     * register：验证码正确但邮箱错误
&nbsp;     * GoodsType：
&nbsp;     * 商品类型添加成功
&nbsp;     * 修改成功
&nbsp;     * 有关联删除失败
&nbsp;     * A002: 成功
&nbsp;     * AUser：密码错误
&nbsp;     * BUser:
&nbsp;     * register：注册成功
&nbsp;     * login：密码错误
&nbsp;     * GoodsType:
&nbsp;     * 商品类型添加失败
&nbsp;     * 修改失败
&nbsp;     * 删除成功
&nbsp;     * A003:不存在，失败
&nbsp;     * Buser：邮箱不存在但注册失败
&nbsp;     * GoodsType:删除失败
&nbsp;     */
<b class="nc">&nbsp;    private String msgId;</b>
&nbsp;    //	存储消息参数的键值对映射
<b class="nc">&nbsp;    private Map&lt;String, String&gt; msgParams;</b>
&nbsp;    //	表示结果类型,主要用于反馈操作结果及状态信息
<b class="nc">&nbsp;    private ResultType resultType;</b>
&nbsp;
<b class="nc">&nbsp;    public ResponseResult() {</b>
&nbsp;    }
&nbsp;
&nbsp;    public ResponseResult(T result, String msgId, ResultType rt, StatusCode statusCode, Map&lt;String, String&gt; msgParams) {
<b class="nc">&nbsp;        super();</b>
<b class="nc">&nbsp;        this.result = result;</b>
<b class="nc">&nbsp;        this.msgId = msgId;</b>
<b class="nc">&nbsp;        this.resultType = rt;</b>
<b class="nc">&nbsp;        this.statusCode = statusCode;</b>
<b class="nc">&nbsp;        this.msgParams = msgParams;</b>
&nbsp;    }
&nbsp;    // 重载ResponseResult方法
&nbsp;
&nbsp;    /**
&nbsp;     * @Description: 操作正常返回
&nbsp;     * @Author: xujia
&nbsp;     * @Date: 2024/9/10  22:59
&nbsp;     * @Param: [res]
&nbsp;     * @version: 1.0
&nbsp;     * @Return: com.ie.common.http.ResponseResult&lt;T&gt;
&nbsp;     **/
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getSuccessResult(T res) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(res, null, ResultType.SUCCESS, StatusCode.C200, null);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * @Description: //TODO
&nbsp;     * @Author: xujia
&nbsp;     * @Date: 2024/9/3  22:23
&nbsp;     * @Param: [res, msgId]
&nbsp;     * @version: 1.0
&nbsp;     * @Return: com.ie.common.http.ResponseResult&lt;T&gt;
&nbsp;     **/
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getMessageResult(T res, String msgId) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(res, msgId, ResultType.MESSAGE, StatusCode.C200, null);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * @Description: //TODO
&nbsp;     * @Author: xujia
&nbsp;     * @Date: 2024/9/10  22:59
&nbsp;     * @Param: [res, msgId, statusCode]
&nbsp;     * @version: 1.0
&nbsp;     * @Return: com.ie.common.http.ResponseResult&lt;T&gt;
&nbsp;     **/
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getMessageResult(T res, String msgId, StatusCode statusCode) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(res, msgId, ResultType.MESSAGE, statusCode, null);</b>
&nbsp;    }
&nbsp;
&nbsp;    // 如下方法都已定义但未在系统中使用
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getSuccessResult(T res, String msgId, Map&lt;String, String&gt; msgParams) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(res, msgId, ResultType.SUCCESS, StatusCode.C200, msgParams);</b>
&nbsp;    }
&nbsp;
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getMessageResult(T res, String msgId, Map&lt;String, String&gt; msgParams) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(res, msgId, ResultType.MESSAGE, StatusCode.C200, msgParams);</b>
&nbsp;    }
&nbsp;
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getMessageResult(T res, String msgId, Map&lt;String, String&gt; msgParams, StatusCode statusCode) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(res, msgId, ResultType.MESSAGE, statusCode, msgParams);</b>
&nbsp;    }
&nbsp;
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getErrorResult(String msgId) {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(null, msgId, ResultType.ERROR, StatusCode.C500, null);</b>
&nbsp;    }
&nbsp;
&nbsp;    public static &lt;T&gt; ResponseResult&lt;T&gt; getNotFoundResult() {
<b class="nc">&nbsp;        return new ResponseResult&lt;T&gt;(null, null, ResultType.NOT_FOUND, StatusCode.C500, null);</b>
&nbsp;    }
&nbsp;
&nbsp;
&nbsp;    public static ResponseResult&lt;Map&lt;String, Object&gt;&gt; error(String 用户_id_不能为空) {
<b class="nc">&nbsp;            return null;</b>
&nbsp;    }
&nbsp;
&nbsp;    public static ResponseResult&lt;Map&lt;String, Object&gt;&gt; success(Map&lt;String, Object&gt; resultMap, String 购物车数据获取成功) {
<b class="nc">&nbsp;            return null;</b>
&nbsp;    }
&nbsp;}
</code>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
      hljs.highlightAll()
      hljs.initLineNumbersOnLoad();
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2025-06-15 18:23</div>
</div>
</body>
</html>
